package com.esri.android.map;

import android.content.Context;
import android.content.res.XmlResourceParser;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.PathShape;
import android.graphics.drawable.shapes.Shape;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Xml;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.FrameLayout;
import com.esri.core.geometry.Point;
import com.github.mikephil.charting.utils.Utils;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

/* loaded from: classes.dex */
public class Callout {
    public static final int ANCHOR_POSITION_FLOATING = 8;
    public static final int ANCHOR_POSITION_LEFT_MIDDLE = 7;
    public static final int ANCHOR_POSITION_LOWER_LEFT_CORNER = 6;
    public static final int ANCHOR_POSITION_LOWER_MIDDLE = 5;
    public static final int ANCHOR_POSITION_LOWER_RIGHT_CORNER = 4;
    public static final int ANCHOR_POSITION_RIGHT_MIDDLE = 3;
    public static final int ANCHOR_POSITION_UPPER_LEFT_CORNER = 0;
    public static final int ANCHOR_POSITION_UPPER_MIDDLE = 1;
    public static final int ANCHOR_POSITION_UPPER_RIGHT_CORNER = 2;
    private static final int c = 12;
    a a;
    boolean b = true;
    private boolean d = false;

    /* JADX INFO: Access modifiers changed from: package-private */
    public Callout(MapView mapView) {
        this.a = new a(mapView);
    }

    public Point getCoordinates() {
        return this.a.c();
    }

    public int getMaxWidth() {
        return this.a.g.getMaxWidth();
    }

    public int getMaxWidthDp() {
        return this.a.g.getMaxWidthDp(this.a.getContext());
    }

    public int getMaxHeight() {
        return this.a.g.getMaxHeight();
    }

    public int getMaxHeightDp() {
        return this.a.g.getMaxHeightDp(this.a.getContext());
    }

    public int[] getOffset() {
        return this.a.d();
    }

    public int[] getOffsetDp() {
        return this.a.e();
    }

    public CalloutStyle getStyle() {
        return this.a.j();
    }

    public void setOffset(int i, int i2) {
        this.a.a(i, i2);
    }

    public void setOffsetDp(int i, int i2) {
        this.a.b(i, i2);
    }

    public void setMaxWidth(int i) {
        this.a.g.setMaxWidth(i);
    }

    public void setMaxWidthDp(int i) {
        this.a.g.setMaxWidthDp(i, this.a.getContext());
    }

    public void setMaxHeight(int i) {
        this.a.g.setMaxHeight(i);
    }

    public void setMaxHeightDp(int i) {
        this.a.g.setMaxHeightDp(i, this.a.getContext());
    }

    public void show() {
        this.a.f();
        this.d = false;
    }

    public void show(Point point) {
        this.a.a(point);
        this.d = false;
    }

    public void show(Point point, View view) {
        this.a.a(point, view, false);
        this.d = false;
    }

    public void animatedShow(Point point, View view) {
        this.a.b(point, view, false);
        this.d = true;
    }

    public void hide() {
        this.a.h();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a() {
        this.a.g();
    }

    public void animatedHide() {
        this.a.i();
    }

    public void move(Point point) {
        this.a.b(point);
    }

    public void setStyle(int i) {
        this.a.a(i);
    }

    void a(AttributeSet attributeSet) {
        this.a.a(attributeSet);
    }

    public void setStyle(CalloutStyle calloutStyle) {
        this.a.a(calloutStyle);
    }

    public void setCoordinates(Point point) {
        this.a.c(point);
    }

    public void setContent(View view) {
        this.a.a(view);
    }

    public void setPassTouchEventsToMapView(boolean z) {
        this.b = z;
    }

    public boolean isPassTouchEventsToMapView() {
        return this.b;
    }

    public boolean isShowing() {
        return this.a.l();
    }

    public void refresh() {
        this.a.m();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class a extends FrameLayout {
        private static final int l = 0;
        private static final int m = 1;
        private static final int n = 2;
        private static final int o = 3;
        private static final int p = 0;
        private static final int q = 1;
        private static final int r = 2;
        private static final int s = 200;
        private static final int t = 20;
        private static final int u = 20;
        private static final int v = -1;
        private Point A;
        private int B;
        private int C;
        private boolean D;
        Point a;
        Point b;
        PointF c;
        int d;
        RectF e;
        View f;
        CalloutStyle g;
        MapView h;
        final Handler i;
        public Path j;
        private final float w;
        private final int x;
        private final int y;
        private C0010a z;

        a(MapView mapView) {
            super(mapView.getContext());
            float f = getResources().getDisplayMetrics().density;
            this.w = f;
            this.A = new Point(Utils.DOUBLE_EPSILON, Utils.DOUBLE_EPSILON);
            this.c = new PointF(0.0f, 0.0f);
            this.d = 1;
            this.e = new RectF();
            this.f = null;
            this.B = -1;
            this.C = -1;
            this.D = false;
            this.g = new CalloutStyle(getContext());
            this.i = new Handler(new Handler.Callback() { // from class: com.esri.android.map.Callout.a.1
                @Override // android.os.Handler.Callback
                public boolean handleMessage(Message message) {
                    int i = message.what;
                    if (i == 0) {
                        a.this.b((View) message.obj);
                    } else if (i == 1) {
                        a.this.setVisibility(0);
                        a.this.D = false;
                    } else if (i == 2) {
                        a.this.n();
                    }
                    return true;
                }
            });
            this.h = mapView;
            setWillNotDraw(false);
            int i = (int) (f * 12.0f);
            this.x = i;
            this.y = i / 2;
            C0010a c0010a = new C0010a(mapView.getContext());
            this.z = c0010a;
            c0010a.setMinimumHeight(this.g.getCornerCurve() * 2);
            this.z.setMinimumWidth(this.g.getCornerCurve() * 2);
            addView(this.z);
            setVisibility(8);
        }

        /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
        private void o() {
            int i;
            int cornerCurve;
            float f;
            int i2;
            int i3;
            Path path = this.j;
            if (path == null) {
                this.j = new Path();
            } else {
                path.reset();
            }
            View view = this.f;
            if (view != null) {
                int measuredWidth = view.getMeasuredWidth() == 0 ? 20 : this.f.getMeasuredWidth();
                int p2 = p();
                if (measuredWidth > p2) {
                    measuredWidth = p2;
                }
                r2 = this.f.getMeasuredHeight() != 0 ? this.f.getMeasuredHeight() : 20;
                int q2 = q();
                if (r2 > q2) {
                    r2 = q2;
                }
                int i4 = r2;
                r2 = measuredWidth;
                i = i4;
            } else {
                i = 20;
            }
            int i5 = 2;
            int cornerCurve2 = r2 + (this.g.getCornerCurve() * 2);
            int i6 = 8;
            float f2 = 0.0f;
            int i7 = 0;
            float f3 = cornerCurve2;
            float cornerCurve3 = i + (this.g.getCornerCurve() * 2);
            char c = 6;
            int i8 = 7;
            PointF[] pointFArr = {new PointF(0.0f, this.g.getCornerCurve()), new PointF(this.g.getCornerCurve(), 0.0f), new PointF(cornerCurve2 - this.g.getCornerCurve(), 0.0f), new PointF(f3, this.g.getCornerCurve()), new PointF(f3, cornerCurve - this.g.getCornerCurve()), new PointF(cornerCurve2 - this.g.getCornerCurve(), cornerCurve3), new PointF(this.g.getCornerCurve(), cornerCurve3), new PointF(0.0f, cornerCurve - this.g.getCornerCurve())};
            this.j.moveTo(pointFArr[0].x, pointFArr[0].y);
            int i9 = 0;
            while (i9 < i6) {
                if (i9 == this.g.a()) {
                    float f4 = cornerCurve3 / 2.0f;
                    float f5 = f3 / 2.0f;
                    switch (this.g.a()) {
                        case 0:
                            Path path2 = this.j;
                            int i10 = this.y;
                            path2.lineTo(-i10, -i10);
                            this.j.lineTo(pointFArr[1].x, pointFArr[1].y);
                            this.c = new PointF(f2, f2);
                            C0010a c0010a = this.z;
                            int i11 = this.y;
                            c0010a.a(i11, i11);
                            C0010a c0010a2 = this.z;
                            int i12 = this.y;
                            c0010a2.b(i12, i12);
                            break;
                        case 1:
                            this.j.lineTo(f5 - this.y, f2);
                            this.j.lineTo(f5, -this.x);
                            this.j.lineTo(this.y + f5, f2);
                            this.j.lineTo(pointFArr[i5].x, pointFArr[i5].y);
                            this.c = new PointF(f5 + this.d, f2);
                            this.z.a(i7, this.x);
                            this.z.b(i7, this.x);
                            break;
                        case 2:
                            Path path3 = this.j;
                            int i13 = this.y;
                            path3.lineTo(cornerCurve2 + i13, -i13);
                            this.j.lineTo(pointFArr[3].x, pointFArr[3].y);
                            this.c = new PointF(this.y + cornerCurve2 + (this.d * 2), f2);
                            this.z.a(i7, this.y);
                            C0010a c0010a3 = this.z;
                            int i14 = this.y;
                            c0010a3.b(i14, i14);
                            break;
                        case 3:
                            this.j.lineTo(f3, f4 - this.y);
                            this.j.lineTo(this.x + cornerCurve2, f4);
                            this.j.lineTo(f3, this.y + f4);
                            this.j.lineTo(pointFArr[4].x, pointFArr[4].y);
                            this.c = new PointF(this.x + cornerCurve2 + (i2 * 2), f4 + this.d);
                            this.z.a(i7, i7);
                            this.z.b(this.x, i7);
                            break;
                        case 4:
                            Path path4 = this.j;
                            int i15 = this.y;
                            path4.lineTo(cornerCurve2 + i15, i15 + cornerCurve);
                            this.j.lineTo(pointFArr[5].x, pointFArr[5].y);
                            int i16 = this.y;
                            int i17 = this.d;
                            this.c = new PointF(cornerCurve2 + i16 + (i17 * 2), i16 + cornerCurve + (i17 * 2));
                            this.z.a(i7, i7);
                            C0010a c0010a4 = this.z;
                            int i18 = this.y;
                            c0010a4.b(i18, i18);
                            break;
                        case 5:
                            this.j.lineTo(this.y + f5, cornerCurve3);
                            this.j.lineTo(f5, this.x + cornerCurve);
                            this.j.lineTo(f5 - this.y, cornerCurve3);
                            this.j.lineTo(pointFArr[c].x, pointFArr[c].y);
                            this.c = new PointF(f5 + this.d, this.x + cornerCurve + (i3 * 2));
                            this.z.a(i7, i7);
                            this.z.b(i7, this.x);
                            break;
                        case 6:
                            Path path5 = this.j;
                            int i19 = this.y;
                            path5.lineTo(-i19, i19 + cornerCurve);
                            this.j.lineTo(pointFArr[i8].x, pointFArr[i8].y);
                            this.c = new PointF(f2, this.y + cornerCurve + (this.d * 2));
                            this.z.a(this.y, i7);
                            C0010a c0010a5 = this.z;
                            int i20 = this.y;
                            c0010a5.b(i20, i20);
                            break;
                        case 7:
                            this.j.lineTo(f2, this.y + f4);
                            this.j.lineTo(-this.x, f4);
                            this.j.lineTo(f2, f4 - this.y);
                            this.j.lineTo(pointFArr[i7].x, pointFArr[i7].y);
                            this.c = new PointF(f2, f4 + this.d);
                            this.z.a(this.x, i7);
                            this.z.b(this.x, i7);
                            break;
                    }
                } else if (i9 < i8) {
                    if (i9 % 2 != 0) {
                        int i21 = i9 + 1;
                        this.j.lineTo(pointFArr[i21].x, pointFArr[i21].y);
                    } else {
                        int i22 = i9 + 1;
                        float min = Math.min(pointFArr[i9].y, pointFArr[i22].y);
                        float max = Math.max(pointFArr[i9].y, pointFArr[i22].y);
                        float min2 = Math.min(pointFArr[i9].x, pointFArr[i22].x);
                        float max2 = Math.max(pointFArr[i9].x, pointFArr[i22].x);
                        if (i9 == 0) {
                            max2 += max2 - min2;
                            max += max - min;
                            f = -180.0f;
                        } else if (i9 != i5) {
                            if (i9 == 4) {
                                min2 -= max2 - min2;
                                min -= max - min;
                            } else if (i9 == 6) {
                                max2 += max2 - min2;
                                min -= max - min;
                                f = 90.0f;
                            }
                            f = 0.0f;
                        } else {
                            min2 -= max2 - min2;
                            max += max - min;
                            f = -90.0f;
                        }
                        this.j.arcTo(new RectF(min2, min, max2, max), f, 90.0f);
                    }
                }
                i9++;
                i6 = 8;
                i5 = 2;
                i7 = 0;
                f2 = 0.0f;
                i8 = 7;
                c = 6;
            }
            this.j.close();
            this.j.computeBounds(this.e, true);
            RectF rectF = this.e;
            int i23 = this.d;
            rectF.inset(-i23, -i23);
            this.j.offset(-this.e.left, -this.e.top);
            b bVar = new b(new PathShape(this.j, this.e.width(), this.e.height()));
            bVar.getPaint().setColor(this.g.getBackgroundColor());
            bVar.getPaint().setAlpha(this.g.getBackgroundAlpha());
            bVar.getPaint().setStrokeWidth(this.d);
            bVar.a(this.g.getFrameColor());
            this.z.setBackgroundDrawable(bVar);
        }

        @Override // android.widget.FrameLayout, android.view.View
        protected void onMeasure(int i, int i2) {
            super.onMeasure(i, i2);
            this.z.a(this.g.getCornerCurve() + this.d);
            o();
            int p2 = p();
            int q2 = q();
            if (p2 != this.B || q2 != this.C) {
                c(p2, q2);
                this.B = p2;
                this.C = q2;
                this.i.sendEmptyMessage(2);
            }
            this.z.c((int) (this.e.width() == 0.0f ? p2 : this.e.width()), (int) (this.e.height() == 0.0f ? q2 : this.e.height()));
        }

        private int p() {
            int width = getWidth();
            if (width == 0) {
                width = r().widthPixels;
            }
            int cornerCurve = (this.g.getCornerCurve() + this.d + (this.x * 2)) * 2;
            int i = width - cornerCurve;
            int maxWidth = this.g.getMaxWidth() - cornerCurve;
            return (maxWidth <= 0 || maxWidth >= i) ? i : maxWidth;
        }

        private int q() {
            int height = getHeight();
            if (height == 0) {
                height = r().heightPixels;
            }
            int cornerCurve = (this.g.getCornerCurve() + this.d + (this.x * 2)) * 2;
            int i = height - cornerCurve;
            int maxHeight = this.g.getMaxHeight() - cornerCurve;
            return (maxHeight <= 0 || maxHeight >= i) ? i : maxHeight;
        }

        private DisplayMetrics r() {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            ((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
            return displayMetrics;
        }

        private void c(int i, int i2) {
            if (this.f != null) {
                this.f.measure(View.MeasureSpec.makeMeasureSpec(i, Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(i2, Integer.MIN_VALUE));
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        public boolean a() {
            boolean a;
            if (this.h.isLoaded() && this.a != null && this.g.getAnchor() == 8) {
                if (this.j == null) {
                    o();
                }
                Rect b2 = b();
                double x = this.a.getX();
                double d = b2.right;
                Double.isNaN(d);
                if (x + d > this.h.d) {
                    a = a(3, b2);
                } else {
                    double x2 = this.a.getX();
                    double d2 = b2.left;
                    Double.isNaN(d2);
                    a = x2 + d2 < Utils.DOUBLE_EPSILON ? a(2, b2) : false;
                }
                double y = this.a.getY();
                double d3 = b2.bottom;
                Double.isNaN(d3);
                if (y + d3 > this.h.e) {
                    a = a(0, b2);
                } else {
                    double y2 = this.a.getY();
                    double d4 = b2.top;
                    Double.isNaN(d4);
                    if (y2 + d4 < Utils.DOUBLE_EPSILON) {
                        a = a(1, b2);
                    }
                }
                if (a) {
                    m();
                }
                return a;
            }
            return false;
        }

        Rect b() {
            Rect rect = new Rect();
            switch (this.g.a()) {
                case 0:
                    return new Rect(0, 0, (int) this.e.width(), (int) this.e.height());
                case 1:
                    return new Rect((-((int) this.e.width())) / 2, 0, ((int) this.e.width()) / 2, (int) this.e.height());
                case 2:
                    return new Rect(-((int) this.e.width()), 0, 0, (int) this.e.height());
                case 3:
                    return new Rect(-((int) this.e.width()), (-((int) this.e.height())) / 2, 0, (int) (this.e.height() / 2.0f));
                case 4:
                    return new Rect(-((int) this.e.width()), (int) (-this.e.height()), 0, 0);
                case 5:
                    return new Rect((-((int) this.e.width())) / 2, (int) (-this.e.height()), ((int) this.e.width()) / 2, 0);
                case 6:
                    return new Rect(0, (int) (-this.e.height()), (int) this.e.width(), 0);
                case 7:
                    return new Rect(0, (-((int) this.e.height())) / 2, (int) this.e.width(), (int) (this.e.height() / 2.0f));
                default:
                    return rect;
            }
        }

        private boolean a(int i, Rect rect) {
            boolean z = rect.width() <= this.h.d / 2;
            boolean z2 = rect.height() <= this.h.e / 2;
            if (i == 0) {
                int a = this.g.a();
                if (a == 0) {
                    if (z2 || this.a.getY() > this.h.e / 3) {
                        return b(7);
                    }
                    return false;
                } else if (a == 1) {
                    if (z2 || this.a.getY() > this.h.e / 2) {
                        return b(5);
                    }
                    return false;
                } else if (a == 2) {
                    if (z2 || this.a.getY() > this.h.e / 3) {
                        return b(3);
                    }
                    return false;
                } else if (a == 3) {
                    if (z2 || this.a.getY() > (this.h.e * 2) / 3) {
                        return b(4);
                    }
                    return false;
                } else if (a != 7) {
                    return false;
                } else {
                    if (z2 || this.a.getY() > (this.h.e * 2) / 3) {
                        return b(6);
                    }
                    return false;
                }
            } else if (i == 1) {
                int a2 = this.g.a();
                if (a2 == 3) {
                    if (z2 || this.a.getY() < this.h.e / 3) {
                        return b(2);
                    }
                    return false;
                } else if (a2 == 4) {
                    if (z2 || this.a.getY() < (this.h.e * 2) / 3) {
                        return b(3);
                    }
                    return false;
                } else if (a2 == 5) {
                    if (z2 || this.a.getY() < this.h.e / 2) {
                        return b(1);
                    }
                    return false;
                } else if (a2 == 6) {
                    if (z2 || this.a.getY() < (this.h.e * 2) / 3) {
                        return b(7);
                    }
                    return false;
                } else if (a2 != 7) {
                    return false;
                } else {
                    if (z2 || this.a.getY() < this.h.e / 3) {
                        return b(0);
                    }
                    return false;
                }
            } else if (i == 2) {
                int a3 = this.g.a();
                if (a3 == 1) {
                    if (z || this.a.getX() < this.h.d / 3) {
                        return b(0);
                    }
                    return false;
                } else if (a3 == 2) {
                    if (z || this.a.getX() < (this.h.d * 2) / 3) {
                        return b(1);
                    }
                    return false;
                } else if (a3 == 3) {
                    if (z || this.a.getX() < this.h.d / 2) {
                        return b(7);
                    }
                    return false;
                } else if (a3 == 4) {
                    if (z || this.a.getX() < (this.h.d * 2) / 3) {
                        return b(5);
                    }
                    return false;
                } else if (a3 != 5) {
                    return false;
                } else {
                    if (z || this.a.getX() < this.h.d / 3) {
                        return b(6);
                    }
                    return false;
                }
            } else if (i != 3) {
                return false;
            } else {
                int a4 = this.g.a();
                if (a4 == 0) {
                    if (z || this.a.getX() > this.h.d / 3) {
                        return b(1);
                    }
                    return false;
                } else if (a4 == 1) {
                    if (z || this.a.getX() > (this.h.d * 2) / 3) {
                        return b(2);
                    }
                    return false;
                } else if (a4 == 5) {
                    if (z || this.a.getX() > (this.h.d * 2) / 3) {
                        return b(4);
                    }
                    return false;
                } else if (a4 == 6) {
                    if (z || this.a.getX() > this.h.d / 3) {
                        return b(5);
                    }
                    return false;
                } else if (a4 != 7) {
                    return false;
                } else {
                    if (z || this.a.getX() > this.h.d / 2) {
                        return b(3);
                    }
                    return false;
                }
            }
        }

        private boolean b(int i) {
            this.g.a(i);
            return true;
        }

        public Point c() {
            return (Point) this.b.copy();
        }

        int[] d() {
            return new int[]{(int) this.A.getX(), (int) this.A.getY()};
        }

        int[] e() {
            double x = this.A.getX();
            double d = this.w;
            Double.isNaN(d);
            double d2 = x / d;
            double y = this.A.getY();
            double d3 = this.w;
            Double.isNaN(d3);
            double d4 = y / d3;
            double signum = Integer.signum((int) d2);
            Double.isNaN(signum);
            double signum2 = Integer.signum((int) d4);
            Double.isNaN(signum2);
            return new int[]{(int) (d2 + (signum * 0.5d)), (int) (d4 + (signum2 * 0.5d))};
        }

        void a(int i, int i2) {
            this.A = new Point(i, i2);
        }

        void b(int i, int i2) {
            double d = i * this.w;
            double signum = Integer.signum(i);
            Double.isNaN(signum);
            Double.isNaN(d);
            int i3 = (int) (d + (signum * 0.5d));
            double d2 = i2 * this.w;
            double signum2 = Integer.signum(i2);
            Double.isNaN(signum2);
            Double.isNaN(d2);
            a(i3, (int) (d2 + (signum2 * 0.5d)));
        }

        public void f() {
            a(this.b);
        }

        public void a(Point point) {
            a(point, this.f, false);
        }

        public void a(Point point, View view, boolean z) {
            if (point == null) {
                return;
            }
            c(point);
            this.f = view;
            if (z || this.h.a()) {
                this.D = true;
                this.i.sendEmptyMessage(1);
                a(view);
                a();
            }
        }

        public void b(Point point, View view, boolean z) {
            if (this.h.isLoaded()) {
                a(point, view, z);
                c(p(), q());
                o();
                ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, this.c.x, this.c.y);
                scaleAnimation.setDuration(200L);
                startAnimation(scaleAnimation);
            }
        }

        void g() {
            if (Callout.this.d) {
                b(this.b, this.f, true);
            } else {
                a(this.b, this.f, true);
            }
        }

        public void h() {
            if (getVisibility() == 0) {
                setVisibility(8);
                m();
            }
        }

        public void i() {
            if (this.h.isLoaded()) {
                ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, this.c.x, this.c.y);
                scaleAnimation.setDuration(200L);
                startAnimation(scaleAnimation);
                scaleAnimation.setAnimationListener(new Animation.AnimationListener() { // from class: com.esri.android.map.Callout.a.2
                    @Override // android.view.animation.Animation.AnimationListener
                    public void onAnimationRepeat(Animation animation) {
                    }

                    @Override // android.view.animation.Animation.AnimationListener
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override // android.view.animation.Animation.AnimationListener
                    public void onAnimationEnd(Animation animation) {
                        a.this.h();
                    }
                });
            }
        }

        void b(Point point) {
            c(point);
            m();
        }

        public CalloutStyle j() {
            return this.g;
        }

        public void a(int i) {
            if (i != -1) {
                XmlResourceParser xml = getContext().getResources().getXml(i);
                while (true) {
                    try {
                        if (xml.getEventType() == 2 && xml.getName().equals("calloutViewStyle")) {
                            break;
                        }
                        xml.next();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (XmlPullParserException e2) {
                        e2.printStackTrace();
                    }
                }
                a(new CalloutStyle(getContext(), Xml.asAttributeSet(xml)));
                xml.close();
                return;
            }
            a(new CalloutStyle(getContext()));
        }

        public void a(AttributeSet attributeSet) {
            a(new CalloutStyle(getContext(), attributeSet));
        }

        public void a(CalloutStyle calloutStyle) {
            if (calloutStyle != null) {
                this.g = calloutStyle;
            }
            m();
        }

        public void c(Point point) {
            this.b = (Point) point.copy();
            this.a = this.h.toScreenPoint(point);
        }

        public void a(View view) {
            this.f = view;
            Message obtainMessage = this.i.obtainMessage(0);
            obtainMessage.obj = view;
            obtainMessage.sendToTarget();
        }

        void b(View view) {
            if (view != null) {
                this.z.a(view);
                this.B = -1;
                this.C = -1;
            }
            n();
        }

        /* JADX INFO: Access modifiers changed from: protected */
        public void k() {
            if (this.h.isLoaded() && this.a != null) {
                this.a = this.h.toScreenPoint(this.b);
            }
            requestLayout();
        }

        public boolean l() {
            if (this.D) {
                return true;
            }
            return isShown();
        }

        public void m() {
            a(this.f);
        }

        void n() {
            this.h.requestLayout();
            this.h.invalidate();
            requestLayout();
            invalidate((int) this.e.left, (int) this.e.top, (int) this.e.right, (int) this.e.bottom);
        }

        @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
        protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
            if (this.a == null && this.b != null && this.h.isLoaded()) {
                c(this.b);
            }
            Point point = this.a;
            if (point == null) {
                super.onLayout(z, i, i2, i3, i4);
                return;
            }
            double x = point.getX();
            double d = this.c.x;
            Double.isNaN(d);
            int x2 = (int) ((x - d) - this.A.getX());
            double y = this.a.getY();
            double d2 = this.c.y;
            Double.isNaN(d2);
            int y2 = (int) ((y - d2) - this.A.getY());
            offsetLeftAndRight(x2);
            offsetTopAndBottom(y2);
            super.onLayout(true, x2, y2, x2 + i3, y2 + i4);
        }

        @Override // android.view.View
        public void draw(Canvas canvas) {
            if (this.a == null && this.b != null && this.h.isLoaded()) {
                c(this.b);
            }
            if (isShown() && this.a != null && this.h.isLoaded()) {
                bringToFront();
                super.draw(canvas);
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        /* loaded from: classes.dex */
        public class b extends ShapeDrawable {
            int a;

            public b(Shape shape) {
                super(shape);
                this.a = 0;
            }

            @Override // android.graphics.drawable.ShapeDrawable
            protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
                paint.setAntiAlias(true);
                paint.setStyle(Paint.Style.FILL);
                shape.draw(canvas, paint);
                int color = paint.getColor();
                int i = this.a;
                if (i == 0) {
                    i = paint.getColor();
                }
                paint.setColor(i);
                paint.setStyle(Paint.Style.STROKE);
                shape.draw(canvas, paint);
                paint.setColor(color);
            }

            public void a(int i) {
                this.a = i;
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        /* renamed from: com.esri.android.map.Callout$a$a  reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public class C0010a extends FrameLayout {
            private int b;
            private int c;
            private FrameLayout d;

            public C0010a(Context context) {
                super(context);
                this.b = 0;
                this.c = 0;
                FrameLayout frameLayout = new FrameLayout(context);
                this.d = frameLayout;
                addView(frameLayout);
            }

            public void a(int i) {
                this.d.setPadding(i, i, i, i);
            }

            public void a(View view) {
                this.d.removeAllViews();
                this.d.addView(view, new FrameLayout.LayoutParams(-2, -2));
            }

            public void a(int i, int i2) {
                this.d.setTranslationX(i);
                this.d.setTranslationY(i2);
            }

            public void b(int i, int i2) {
                this.b = i;
                this.c = i2;
            }

            public void c(int i, int i2) {
                setMeasuredDimension(i, i2);
            }

            @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
            protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
                this.d.layout(i, i2, i3 - this.b, i4 - this.c);
            }

            @Override // android.view.View
            public boolean onTouchEvent(MotionEvent motionEvent) {
                return !Callout.this.b;
            }
        }
    }
}
